import ms from 'ms';
import { WARNING_CATEGORY_KEY_LABEL_MAP } from './common/constants';

// 验证码重新发送间隔
const verificationCodeResendInterval = 2 * 60 * 1000;
const vulCategoryMap = WARNING_CATEGORY_KEY_LABEL_MAP.vul;

export default {
	serviceUrl: 'http://10.255.8.129:60060/#',

	casAppId: 'yjc',
	// 网站画像
	cydEnabledApi: 'http://console-dev1.scanv.com/api/v2/jobs/cyd_enabled',
	serviceApi: 'http://api.dev.scanv.com',
	token:
		'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjYwODdkMDZkYzFiZWM2MDAxYjk4NWVlOSIsImVudGl0eVR5cGUiOiJhcHAiLCJpYXQiOjE2MTk1MTM0NTMsImV4cCI6MTg4NjgzNTA1M30.72sDGIw9PoqoGz8mljOQKfBumnaiL1Rrgb2Bh7HrbEQ',
	// 微信
	wechatSendMessageApi: 'http://wx.yunaq.com/wechat/send_msg',
	wechatUser: 'KS_user',
	wechatPassword: '',
	wechatAlertTemplateId: 'nYSlrlA4dKS9AhTa8TCxdxSgDFdJr9vW5ph4BI9UT3g',
	wechatReverseTemplateId: '_TxHU9tt3evu8CEe3CEvLnnU0E_UtuCjBE1lapAjHAc',

	systemMailFrom: 'notice@jk.yunaq.com',

	verificationCodeResendInterval,
	// 验证码过期时间
	verificationCodeExpire: 20 * 60 * 1000,

	alertSign: '【ScanV】',

	// 云片
	yunpianSingleApi: 'https://sms.yunpian.com/v2/sms/tpl_single_send.json',
	yunpianBatchApi: 'https://sms.yunpian.com/v2/sms/batch_send.json',
	yunpianTplBatchApi: 'https://sms.yunpian.com/v2/sms/tpl_batch_send.json',
	yunpianApiKey: '80b749f74e1cbf00cbf2568ab2a0665e',

	// 【ScanV】#domain#于#time##way##type#监测中发现#details#，请及时修复。
	yunpianTplIdWeakness: '3901000',
	// 【ScanV】#domain#监测的可用性#type#任务：#url# ，于#time#发现有#num#个监测点#details#。
	yunpianTplIdAviliable: '5238782',
	// 【ScanV】#domain#于#time#资产变动监测中发现#details#。
	yunpianTplIdAsset: '5238778',
	// 【ScanV】您的验证码：#code#，该验证码有效期5分钟，请及时验证。
	yunpianTplIdVerification: '5238810',
	// 【Sacnv MAX】套餐#edition#,即将到期#close_time#
	yunpianSmsImdiatelyExpire: '4327996',
	// 【Sacnv MAX】套餐#edition#,已经到期
	yunpianSmsYetExpire: '4328002',
	// 【Sacnv MAX】URL不足一万条
	yunpianUrltimesUnable: '4328004',
	// 【Sacnv MAX】URL达到上限
	yunpianUrlNot: '4328006',
	// 模版名
	// 【Sacnv MAX】套餐#edition#,即将到期#close_time#
	comboWillExpire: 'scanvmax_plan_will_expire',
	// 【Sacnv MAX】套餐#edition#,已经到期
	comboYetExpire: 'scanvmax_plan_expired',
	// 【Sacnv MAX】URL不足一万条
	urlWillExpire: 'scanvmax_plan_maxpage_will_useup',
	// 【Sacnv MAX】URL达到上限
	urlYetExpire: 'scanvmax_plan_maxpage_useup',

	emailTemplateDict: {
		scanvmax_plan_will_expire: 'ScanV 提醒：您的套餐服务即将到期',
		scanvmax_plan_expired: 'ScanV 提醒：您的套餐服务已到期',
		scanvmax_plan_maxpage_will_useup: 'ScanV 提醒：您的URL扫描数即将耗尽',
		scanvmax_plan_maxpage_useup: 'ScanV 提醒：您的URL扫描数已达上限',
	},

	yunaqDomainCheck: {
		api: 'http://manage-ui-dev4.k8s.cloud/api/inner/user_domain_valid/',
		credentials: Buffer.from('test:test1').toString('base64'),
	},

	docgenApi:
		'http://200-chengdu-hwd-iptag1.intra.jiasule.com:8480/api/v1/docgen',

	parseTaskResultInterval: ms('2m'),

	defaultAssetSettings: {
		alertSettings: {
			enable: true,
			alertGroupIds: [],
			notification: {
				email: true,
				sms: false,
				wechat: false,
				inBox: true,
			},
		},
		taskSettings: {
			enable: true,
			target: '',
			collect: {
				ipBindDomain: true,
				subdomain: true,
				port: true,
			},
			interval: ms('1d'),
			alert: {},
		},
	},
	sitePortraitSettings: {
		alertSettings: {
			enable: true,
			alertGroupIds: [],
			notification: {
				email: true,
				sms: false,
				wechat: false,
				inBox: true,
			},
		},
		taskSettings: {
			enable: true,
			collect: {
				ipBindDomain: true,
			},
			interval: ms('1w'),
			alert: {
				enable: true,
				pathChange: true,
			},
		},
	},
	sitePortraitRepeatTask: {
		limit: 10000,
		interval: ms('2h'),
		dataSource: {
			api: '',
			tableName: 'access',
		},
	},
	sendEmailInfo: {
		apiUser: 'zhangzl_test_D8Bw25',
		apiKey: 'J1ANpzBISzEB8yvL',
		from: 'zhangzl@knownsec.com',
	},
	__browser: {
		verificationCodeResendInterval,
		// 主页最近监测次数限制
		homeLastestCount: 10,
		logo: 'https://www.scanv.com/static/logo.svg',
		settingOptions: {
			depthOptions: [
				{ label: 1, value: 1 },
				{ label: 2, value: 2 },
				{ label: 3, value: 3 },
				{ label: 4, value: 4 },
				{ label: 5, value: 5 },
				{ label: 10, value: 10 },
			],
			maxPageOptionsContent: [50, 100, 200, 300, 500, 1000],
			maxPageOptions: [
				50,
				100,
				200,
				300,
				500,
				1000,
				5000,
				10000,
				50000,
				100000,
			],
			alertOptions: [
				{
					label: '高危',
					value: 'high',
				},
				{
					label: '中危',
					value: 'medium',
				},
				{
					label: '低危',
					value: 'low',
				},
			],
			collectSpeed: [
				{
					label: '高速',
					value: 'high',
				},
				{
					label: '快速',
					value: 'medium',
				},
				{
					label: '普通',
					value: 'low',
				},
			],
			// 漏洞检测模式
			vulPattern: [
				{
					label: '仅高危',
					value: 'high',
				},
				{
					label: '高、中、低危',
					value: 'medium',
				},
			],
		},
		vulType: ['webvul', 'command_execution', 'injection'],
		vulFullSettings: {
			enable: true,
			// 采集规则
			collect: {
				type: 'full',
				speed: 'medium',
				depth: 3,
				maxPage: 1000,
			},
			// 告警策略
			alert: {
				enableSmartMode: true,
				vulLevel: {
					high: true,
					medium: true,
					low: true,
				},
				// 漏洞类型
				vulType: Object.keys(vulCategoryMap),
			},
			interval: ms('1w'),
		},
		defaultJobSettings: {
			target: {
				protocol: 'https:',
			},
			enableMonitor: false,
			enableAlert: true,
			securityEventSettings: {
				enable: true,
				collect: {
					plugins: ['black_links', 'cryjack', 'malscan', 'broken_links'],
					depth: 3,
					maxPage: 1000,
					speed: 'high',
				},
				interval: ms('1d'),
			},
			vulSettings: {
				enable: true,
				// 采集规则
				collect: {
					type: 'increment',
					speed: 'medium',
					depth: 3,
					maxPage: 1000,
				},
				// 告警策略
				alert: {
					enableSmartMode: true,
					vulLevel: {
						high: true,
						medium: true,
						low: true,
					},
					// 漏洞类型
					vulType: Object.keys(vulCategoryMap),
				},
				interval: ms('1w'),
			},
			sslSettings: {
				enable: true,
				collect: {
					pluginCategories: ['certificate', 'protocol'],
				},
				alert: { enable: true },
				interval: ms('1w'),
			},
			httpSettings: [
				{
					enable: true,
					name: '首页',
					target: '',
					collect: {
						area: [
							'dalian-ctc1',
							'zhuzhou-cuc1',
							'hengyang-ctc1',
							'nanchang-ctc1',
							'xiangyang-cmc1',
						],
						area_ipv6: [
							'dalian-ctc1',
							'suqian-cuc1',
							'nanchang-ctc1',
							'xiangyang-cmc1',
							'tianjin-ctc1',
						],
						method: 'get',
						redirect: 3,
					},
					alert: {
						respTime: 12000,
						innerType: 'statusCodeRange',
						statusCodeRange: [[400, 599]],
						nodeCount: 5,
						alertCount: 1,
						enableSmartMode: true,
					},
					interval: ms('15m'),
				},
			],
			contentSettings: {
				enable: true,
				collect: {
					plugins: ['keyword', 'privacy_disclosure'],
					depth: 3,
					maxPage: 1000,
					includeUrl: [],
					systemKeywordTypes: [1, 2, 3, 4, 5, 6, 7, 8],
					customKeywordTypes: [1, 2, 3, 4, 5, 6, 7, 8],
					privacyDisclosureTypes: [1, 2, 3, 4],
				},
				interval: ms('1d'),
			},
			pingSettings: [
				{
					enable: true,
					name: '默认',
					sourceIp: null,
					target: '',
					collect: {
						area: [
							'dalian-ctc1',
							'zhuzhou-cuc1',
							'hengyang-ctc1',
							'nanchang-ctc1',
							'xiangyang-cmc1',
						],
						area_ipv6: [
							'dalian-ctc1',
							'suqian-cuc1',
							'nanchang-ctc1',
							'xiangyang-cmc1',
							'tianjin-ctc1',
						],
					},
					alert: {
						respTime: 1000,
						lossRate: 50,
						nodeCount: 5,
						alertCount: 1,
					},
					interval: ms('15m'),
				},
			],
			alertSettings: {
				alertGroupIds: [],
				enable: {
					asset: true,
					vul: true,
					cyd: true,
					ssl: true,
					securityEvent: true,
					http: true,
					ping: true,
					content: true,
				},
				notification: {
					email: true,
					sms: true,
					wechat: true,
					inBox: true,
				},
				smsAllowedTime: {
					start: '00:00:00',
					end: '23:59:59',
				},
				emailAllowedTime: {
					start: '00:00:00',
					end: '23:59:59',
				},
				smsDailyLimit: 10,
				emailDailyLimit: 10,
			},
			prelogin: {
				site_login: false,
				login_method: 'form', // 登陆方式【form，json，cookie，headers】
				login_form_action_url: '',
				login_form_postdata: '',
				login_json_action_url: '',
				login_json_postdata: '',
				request_cookie: '',
				request_http_headers: '',
				is_http_auth_enabled: false, // http认证开关
				http_auth_username: '',
				http_auth_password: '',
				is_proxy_enabled: false, // 代理开关
				proxy_scheme: 'http',
				proxy_host: '',
				proxy_port: 80,
				proxy_username: '',
				proxy_password: '',
			},
		},
		casUrl: 'http://0:9000',
		consoleLink: 'https://defense.yunaq.com/site/',
		newsIUrl: 'https://www.scanv.com/',
	},
};
